import 'package:dio/dio.dart';
import 'package:mi_mang_flutter/network/extra_keys.dart';

import '../model/public/entity_factory.dart';
import '../network/response_data.dart';
import '../network/client.dart';

/// 短信管理接口
class SmsApi {
  static const String API_SMS_SEND_VALID_NUMBER = "/api/sms/send_valid_number";

  /// 发送短信
  /// [phoneNumber] 手机号码(不为空)
  static Future<ResponseData> sendValidNumber(String phoneNumber) async {
    var response = await client.get(
      API_SMS_SEND_VALID_NUMBER,
      queryParameters: {"phoneNumber": phoneNumber},
      options: Options(extra: {
        ExtraKeys.NEED_TOKEN: false,
      }),
    );
    return ResponseData(
      code: response.code,
      msg: response.msg,
      data: EntityFactory.generateOBJ(response.data),
    );
  }
}
